<template>
	<view class="body">
		<view>
			<view v-for="item in data" class="card" @click="setIndex(item.id)">
				<view style="display: flex;">
					<view style="display: flex;justify-content: center;align-items: center;">
						<view class="yuan"></view>
					</view>

					<view class="title">
						{{item.createdAt?.replace(/\+.*$/, '').replace('T', ' ').replace(/\.\d+$/, '').replace(/(\d{4})-(\d{2})-(\d{2})/, '$1年$2月$3日').slice(0,11)}}健康档案记录
					</view>
				</view>
				<view class="line"></view>
				<view class="detail_time">详细时间：{{item.createdAt?.replace(/\+.*$/, '').replace('T', ' ').replace(/\.\d+$/, '')}}</view>
				<!-- <view class="title"> 生成时间:{{item.createdAt?.replace(/\+.*$/, '').replace('T', ' ').replace(/\.\d+$/, '')}}</view> -->
			</view>
			<view
				style="display: flex;justify-content: center;align-items: center;width: 90%;margin: 0 auto;margin-top: 30rpx;">
				没有更多数据了...</view>

		</view>
	</view>
</template>

<script setup>
	import {
		getcreateHealthRecordHistory,
		createHealthRecord
	} from '@/request/health.js'
	import {
		onMounted,
		ref
	} from 'vue';
	import {
		onLoad
	} from '@dcloudio/uni-app';
	const phone = ref("")
	const data = ref("")

	const orderId = ref("")
	onLoad((option) => {
    console.log(option)
		orderId.value = option.orderId
		getcreateHealthRecordHistory(option.orderId).then(res => {
			data.value = res.data.list
		}).catch(err => {

		})
	})
	onMounted(() => {

		// healthhistory(phone.value,user_accounts_id.value).then(res => {
		//   const lastItem = res.result.data;
		//   // const newArray = [lastItem];
		//   data.value = lastItem
		//   console.log(data.value)
		// }).catch(err => {

		// })

	})
	const setIndex = (id) => {
		uni.setStorageSync("keyid", id)
		uni.navigateTo({
			url: `/pages/healthrecord/detail?orderId=${orderId.value}&id=${id}`
		})
	}
</script>

<style>
	.detail_time {
		margin-left:50rpx;
		height:50rpx;
		display: flex;
		align-items: center;
		font-size: 20rpx;
	}
	.body {
		height: 100vh;
		overflow-y: scroll;
		display: felx;
		flex-direction: column;
		justify-content: center;
		align-items: center;
		background-color: rgb(218, 232, 242);
	}

	.card {
		width: 90%;
		margin: 0 auto;
		min-height: 150rpx;
		display: flex;
		flex-direction: column;
		justify-content: center;
		/* align-items: center; */
		border-radius: 15rpx;
		margin-top: 20rpx;

		background-color: white;
	}

	.yuan {
		width: 40rpx;
		/* 圆的宽度 */
		height: 40rpx;
		/* 圆的高度 */
		background-color: #46B6FE;
		/* 圆的背景颜色 */
		border-radius: 50%;
		margin-left: 20rpx;
	}

	.title {
		display: flex;
		align-items: center;
		justify-content: center;
		align-items: center;
		font-size: 28rpx;
		font-weight: 400;
		letter-spacing: 2rpx;
		line-height: 28.96px;

		color: rgba(0, 0, 0, 1);
		margin-left: 10rpx;
	}

	.line {
		width: 604rpx;
		margin: 0 auto;
		height: 0px;
		opacity: 1;
		margin-top: 10rpx;
		border: 1px solid rgba(230, 230, 230, 1);
	}
</style>
